package com.bsoft.gol.hcs.service.rpc.impl;

import com.alibaba.fastjson.JSONArray;
import ctd.controller.exception.ControllerException;
import ctd.spring.boot.annotation.SsdevService;
import ctd.util.annotation.RpcService;
import hcn.request.CaseInfoRemindChangeRequest;
import hcn.request.CaseInfoRemindRequest;
import hcn.response.CaseInfoRemindChangeReponse;
import hcn.response.CaseInfoRemindReponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.bsoft.gol.hcs.service.rpc.CaseQualityConRemindRpcService;
import com.bsoft.gol.hcs.utils.JSONDateUtil;

/**
 * @program: 3.4.02
 * @description: 质控提醒
 * @author: zangsf
 * @create: 2021-08-30 14:58
 **/
@SsdevService("caseQualityConRemindRpcService")
public class CaseQualityConRemindRpcServiceImpl implements CaseQualityConRemindRpcService {
    private static final Logger logger = LoggerFactory.getLogger(CaseQualityConRemindRpcServiceImpl.class);

    @Override
    @RpcService
    public CaseInfoRemindReponse getMedicalRecordRemind(CaseInfoRemindRequest req) throws ControllerException {
//        CaseInfoRemindReponse medicalRecordRemind = null;
//        try {
//            medicalRecordRemind = (CaseInfoRemindReponse) Client.rpcInvoke("hcr.caseQualityConRemindLocalService", "getMedicalRecordRemind", req);
//        } catch (Exception e) {
//            logger.error("查询医生信息失败：" + e.getMessage());
//            throw new ControllerException("查询医生信息失败");
//        } catch (Throwable throwable) {
//            throwable.printStackTrace();
//        }
        //假数据
        String json = JSONDateUtil.readFile("getMedicalRecordRemind");
        CaseInfoRemindReponse medicalRecordRemind = new CaseInfoRemindReponse();
        CaseInfoRemindReponse caseInfoRemindReponse = JSONArray.parseObject(json, CaseInfoRemindReponse.class);
        return caseInfoRemindReponse;
    }

    @Override
    @RpcService
    public CaseInfoRemindChangeReponse getMedicalRecordRectification(CaseInfoRemindRequest req) throws ControllerException {
//        CaseInfoRemindChangeReponse rectification = null;
//        try {
//            rectification = (CaseInfoRemindChangeReponse) Client.rpcInvoke("hcr.caseQualityConRemindLocalService", "getMedicalRecordRectification", req);
//        } catch (Exception e) {
//            logger.error("查询医生信息失败：" + e.getMessage());
//            throw new ControllerException("查询医生信息失败");
//        } catch (Throwable throwable) {
//            throwable.printStackTrace();
//        }
        //假数据
        String json = JSONDateUtil.readFile("getMedicalRecordRectification");
        CaseInfoRemindChangeReponse caseInfoRemindChangeReponse = JSONArray.parseObject(json, CaseInfoRemindChangeReponse.class);
        return caseInfoRemindChangeReponse;
    }

    @Override
    @RpcService
    public Integer addMedicalRecordRectification(CaseInfoRemindChangeRequest req) throws ControllerException {
        Integer data = null;
//        try {
//            data = (Integer) Client.rpcInvoke("hcr.caseQualityConRemindLocalService", "addMedicalRecordRectification", req);
//        } catch (Exception e) {
//            logger.error("查询医生信息失败：" + e.getMessage());
//            throw new ControllerException("查询医生信息失败");
//        } catch (Throwable throwable) {
//            throwable.printStackTrace();
//        }
//        return data;
        return 5;
    }

    public static void main(String[] args) {
        CaseQualityConRemindRpcServiceImpl caseQualityConRemindRpcService = new CaseQualityConRemindRpcServiceImpl();
        CaseInfoRemindChangeReponse medicalRecordRectification = null;
        try {
            medicalRecordRectification = caseQualityConRemindRpcService.getMedicalRecordRectification(null);
        } catch (ControllerException e) {
            e.printStackTrace();
        }
        System.out.println(medicalRecordRectification);
    }
}
